package aad.storyboard.controller;

import aad.storyboard.R;
import aad.storyboard.model.AnimationProvider;
import aad.storyboard.model.Story;
import aad.storyboard.model.menu.MenuProvider;
import aad.storyboard.view.PauseButton;
import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;

/**
 * Command pattern: is triggered by the NavigationOnClickListener if the PauseButton is clicked 
 */
public class PauseNavigator implements NavigateCommand{	
	AudioPlayer player=AudioPlayer.getInstance();
	private Activity activity;
	
	public PauseNavigator(Activity a)
	{
		this.activity=a;
	}
	
	/**
	 * pauses the audio playback and all running Animations and triggers the Pause menu
	 */
	@Override
	public void navigate() {
		player.pauseAudio();
		AnimationProvider.getInstance().pauseAllActiveAnimations();		
		View pauseView=MenuViewProvider.getInstance().getPauseMenuView();
		if(pauseView.getParent() != null){
			((ViewGroup)pauseView.getParent()).removeView(pauseView);
		}
		activity.setContentView(pauseView);		
		
	}

}
